/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ceair.flight.refund.util;



import com.ceair.flight.refund.dto.external.BaseRefundRequest;
import com.ceair.flight.refund.dto.external.InitialContext;
import com.ceair.flight.refund.dto.external.PnrDetailsRes;
import com.ceair.flight.refund.dto.external.TicketPnrCancelDate;
import com.ceair.flight.refund.dto.external.ValueType;
import com.ceair.flight.refund.location.model.FlightOrderDO;
import com.ceair.flight.refund.location.model.OrderDO;

import com.ceair.flight.refund.location.model.PayDO;
import com.ceair.muibe.provider.tkt.DetrTktInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 *
 * @author Colin_You
 */
public final class RequestsUtil {

    private static final Logger LOG = LoggerFactory.getLogger(RequestsUtil.class);
    private static final InitialContext INITIAL_CONTEXT = InitialContext.INSTANCE;

    public static OrderDO getBigOrder(BaseRefundRequest request) {
        Object result = INITIAL_CONTEXT.getValue(request, ValueType.ORDER);
        return result == null ? null : (OrderDO) result;
    }

    public static List<PayDO> getPayments(BaseRefundRequest request) {
        Object result = INITIAL_CONTEXT.getValue(request, ValueType.PAYMENT);
        return result == null ? null : (List<PayDO>) result;
    }

    public static FlightOrderDO getFlightOrder(BaseRefundRequest request) {
        Object result = INITIAL_CONTEXT.getValue(request, ValueType.FLIHGTORDER);
        return result == null ? null : (FlightOrderDO) result;
    }

    public static List<DetrTktInfo> getDetrs(BaseRefundRequest request) {
        Object result = INITIAL_CONTEXT.getValue(request, ValueType.DETR);
        return result == null ? null : (List<DetrTktInfo>) result;
    }

    public static List<TicketPnrCancelDate> getPnrCancelDates(BaseRefundRequest request) {
        Object result = INITIAL_CONTEXT.getValue(request, ValueType.PNR_CANCEL_DATE);
        return result == null ? null : (List<TicketPnrCancelDate>) result;
    }

    public static PnrDetailsRes getPnrDetail(BaseRefundRequest request) {
        Object result = INITIAL_CONTEXT.getValue(request, ValueType.PNR_DETAIL);
        return result == null ? null : (PnrDetailsRes) result;
    }

    public static void clear(BaseRefundRequest request) {
        INITIAL_CONTEXT.clearValue(request);
    }
}
